﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YiNing.Tools;

namespace Lixun
{
    //[TypeConverter(typeof(CategoriesSortedByClassDefinitionConverter))]

    public class BaseParameters
    {
        [Category("基础参数")]
        [DisplayName("接口地址")]
        //[ReadOnly(true)]
        public string MesUrl { get; set; }
        [Category("基础参数")]
        [DisplayName("本机IP")]
        public string Ip { get; set; }

        [Category("基础参数")]
        [DisplayName("WorkOrder")]
        [Description("工单号（暂无需）	OP手动输入工单")]
        public string WorkOrder { get; set; }
        [Category("基础参数")]
        [DisplayName("TerminalID[1轨]")]
        [Description("测试机节点ID（MES中站点名称）Station ID（1轨或2轨可上传不同的节点ID）")]
        public string TerminalID1 { get; set; }

        [Category("基础参数")]
        [DisplayName("TerminalID[2轨]")]
        [Description("测试机节点ID（MES中站点名称）Station ID（1轨或2轨可上传不同的节点ID）")]
        public string TerminalID2 { get; set; }
        [Category("基础参数")]
        [DisplayName("MachineType")]
        [Description("MachineType	SPI或者AOI")]
        public string MachineType { get; set; }

        [Category("基础参数")]
        [DisplayName("OperatorID")]
        [Description("中控或本地操作员ID")]
        public string OperatorID { get; set; }

        [Category("其他参数")]
        [DisplayName("错误代码")]
        [Description("添加相应的错误代码信息")]
        [NotMapped]
        public List<ErrorCode> ErrorCodes { get; set; }

        public BaseParameters()
        {
            ErrorCodes = new List<ErrorCode>();
        }



        public enum ResultTypeCn
        {
            OK = 0,//AOI端没有OK项，这里从aoi转换后要加1
            默认,
            本体定位,
            焊盘定位,
            偏移,
            少锡,
            多锡,
            虚焊,
            假焊,
            空焊,
            立碑,
            少件,
            多件,
            错件,
            翻件,
            连桥,
            丝印,
            极性,
            翘脚,
            损件,
            PIN歪,
            散热片漏贴,
            插反,
            浮高,
            破损,
        }

        public enum ResultType
        {
            OK = 0,//AOI端没有OK项，这里从aoi转换后要加1
            Default,
            BodySearch,
            PadSearch,
            Shift,
            SoderLess,
            SolderExcessive,
            SolderWelding,
            SolderNotReal,
            SolderOpen,
            Tombstand,
            MissingComponent,
            MultipleComponent,
            MixedComponent,
            FlipComponent,
            SolderShort,
            SickScreen,
            WrongPolarity,
            LeadFail,
            BrokenComponent,
            PinCrooked,
            MissingHeatSink,
            BackwardComponent,
            HighPosition,
            Broken,
        }
        public class ErrorCode
        {
            [Category("参数绑定")]
            [DisplayName("设备错误信息序号")]
            [Description("AOI对应的错误信息序号")]
            [ReadOnly(true)]
            public int ErrorCodeIndex { get; set; }

            [Category("参数绑定")]
            [DisplayName("设备错误信息")]
            [Description("AOI对应的错误信息")]
            [ReadOnly(true)]
            public string ErrorCodeAOI { get; set; }

            [Category("参数绑定")]
            [DisplayName("MES对应的错误信息")]
            [Description("MES对应的错误信息")]
            public string ErrorCodeMES { get; set; }
        }
    }
}
